#ifndef MEASCONNECTIONHANDLER_H
#define MEASCONNECTIONHANDLER_H

#include <iostream>
#include <list>
#include <boost/weak_ptr.hpp>
#include <boost/shared_ptr.hpp>
#include "measurement/MeasBase.hpp"

namespace core {

struct MeasConnection;

typedef boost::weak_ptr<measurement::MeasBase> WeakMOPtr;
typedef boost::shared_ptr<measurement::MeasBase> SharedMOPtr;
typedef std::list<std::wstring> ConnectionTypes;
typedef std::list<MeasConnection*> ConnectionsList;

struct MeasConnection {
    WeakMOPtr first;
    WeakMOPtr second;
    ConnectionTypes* connTypes;

    ~MeasConnection();
};

class MeasConnectionHandler {
    ConnectionsList connections;

    bool matchTypes(boost::shared_ptr<measurement::MeasurementObject> from,
                    boost::shared_ptr<measurement::MeasurementObject> to,
                    ConnectionTypes** connTypes);
public:
    MeasConnectionHandler();
    ~MeasConnectionHandler();

    void connect(boost::shared_ptr<measurement::MeasBase> mo);
    void disconnect(boost::shared_ptr<measurement::MeasBase> mo);
    ConnectionsList &getConnections();
};

}

#endif // MEASCONNECTIONHANDLER_H
